<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>选择考试</title>
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/studentIndex.css">
    <link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/common.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/page/admin/lib/layer/2.4/layer.js"></script>
    <script type="text/javascript">
        // 开始考试
        function startExam() {
            var t = $("#subject option:selected").val();
            if (t == 0) {
                // 是否已经选择了要考试的科目
                layer.msg("请先选择科目",{icon:2,time:2000});
            } else {
                location.replace("${pageContext.request.contextPath}/Index/main?subjectId=" + t.trim());
            }
        }

        // 退回到登陆界面
        function quitSystem() {
            location.replace("${pageContext.request.contextPath}/login.jsp");
        }
    </script>
</head>
<body>
<form>

    <div class="clearfix student_page">

        <div class="left student_main">
            <%--学生的照片--%>
            <div class="left student_img">
                <img style="width: 100%;height: 100%;margin-top: 38%;"
                     src="${pageContext.request.contextPath}/static/img/studentImg.jpg">
            </div>
                <%--学生的信息--%>
            <div class="left student_infor">

                <table style="width: 100%;height: 100%;">
                    <tr class="student_tr_style">
                        <td class="student_td_left">学号：</td>
                        <td>${student.sno}</td>
                    </tr>

                    <tr class="student_tr_style">
                        <td class="student_td_left">姓名：</td>
                        <td>${student.studentName}</td>
                    </tr>

                    <tr class="student_tr_style">
                        <td class="student_td_left">专业：</td>
                        <td>${student.classes.major.majorName}</td>
                    </tr>

                    <tr class="student_tr_style">
                        <td class="student_td_left">班级：</td>
                        <td>${student.classes.classesName}</td>
                    </tr>

                    <tr class="student_tr_style">
                        <td class="student_td_left">选择考试科目：</td>
                        <td>
                            <select id="subject" style="width: 70%;">
                                <option name="subjectName" value="0"> 请选择考试科目</option>
                                <c:forEach items="${subjects}" var="s">
                                    <option name="subjectName" value="${s.id}"> ${s.subjectName}</option>
                                </c:forEach>
                            </select>
                        </td>
                    </tr>

                    <tr class="student_tr_style">
                        <td colspan="2" align="center">
                            <input type="button" value="开始考试" style="margin-top: 5%;width: 18%;" onclick="startExam()">
                            <input type="button" value="退出" style="margin-left: 10%;margin-top:5%;width: 17%;" onclick="quitSystem()">
                        </td>
                    </tr>
                </table>
            </div>

        </div>
        <%--显示该学生已经考过科目的成绩--%>
        <div class="left" style="width: 30%;margin-top: 10%;margin-left: 2%;">
            <table border="1px" style="border-collapse: collapse;width: 50%;border:3px  groove #ADFF2F">
                <tr class="student_tr_style">
                    <td align="center">已考科目</td>
                    <td align="center">成绩</td>
                </tr>
                <c:forEach items="${scores}" var="score" varStatus="vs">
                    <c:forEach items="${scoresSubject}" var="ss" begin="${vs.count - 1}" end="${vs.count - 1}">
                        <tr class="student_tr_style" align="center">
                            <td class="student_td_left">${ss.subjectName}</td>
                            <td>${score.result}</td>
                        </tr>
                    </c:forEach>
                </c:forEach>
            </table>
        </div>
    </div>

</form>
</body>
</html>